{
"/* COMPATIBILITY \n"
"   - HLSL compilers\n"
"   - Cg   compilers\n"
"*/\n"
"\n"
"/*\n"
"   Dot Mask\n"
"   Author: cgwg\n"
"   License: GPL\n"
"   \n"
"   Note: This shader is just the dotmask code from cgwg's CRT shader.\n"
"*/\n"
"\n"
"struct input\n"
"{\n"
"   float2 video_size;\n"
"   float2 texture_size;\n"
"   float2 output_size;\n"
"   float  frame_count;\n"
"   float  frame_direction;\n"
"   float frame_rotation;\n"
"   sampler2D texture : TEXUNIT0;\n"
"};\n"
"\n"
"void main_vertex\n"
"(\n"
"   float4 position : POSITION,\n"
"   out float4 oPosition : POSITION,\n"
"   uniform float4x4 modelViewProj,\n"
"\n"
"   float4 color : COLOR,\n"
"   out float4 oColor : COLOR,\n"
"\n"
"   float2 texCoord : TEXCOORD,\n"
"   out float2 oTexCoord : TEXCOORD,\n"
"\n"
"   uniform input IN\n"
")\n"
"{\n"
"   oPosition = mul(modelViewProj, position);\n"
"   oColor = color;\n"
"   oTexCoord = texCoord;\n"
"}\n"
"\n"
"#define mod_factor texCoord.x * IN.texture_size.x * IN.output_size.x / IN.video_size.x\n"
"\n"
"#pragma parameter DOTMASK_STRENGTH \"Dot Mask Strength\" 0.3 0.0 1.0 0.01\n"
"\n"
"#ifdef PARAMETER_UNIFORM\n"
"uniform float DOTMASK_STRENGTH;\n"
"#else\n"
"#define DOTMASK_STRENGTH 0.3\n"
"#endif\n"
"\n"
"float4 main_fragment (in float2 texCoord : TEXCOORD, uniform input IN) : COLOR\n"
"{\n"
"   float3 res = tex2D(IN.texture, texCoord);\n"
"   \n"
"   float mask = 1.0 - DOTMASK_STRENGTH;\n"
"   \n"
"   // dot-mask emulation:\n"
"   // Output pixels are alternately tinted green and magenta.\n"
"   float3 dotMaskWeights = lerp(\n"
"                           float3(1.0, mask, 1.0),\n"
"                           float3(mask, 1.0, mask),\n"
"                           floor(fmod(mod_factor, 2.0))\n"
"						   );\n"
"   res *= dotMaskWeights;\n"
"\n"
"      return float4(res, 1.0);\n"
"}\n"
},
